{{include file="header_inc.html"}}
<script type="text/javascript">	
$(document).ready(function() {
	window.top.$('#display_center_id').css('display', 'none');
});

	function deleteComment(id) {
		if (id == '') {
			window.top.art.dialog({icon: 'error',content:'参数错误!'});
		}
		art.dialog({
		    content: '你确定删除吗?',
		    ok: function () {
		    	$.post('/content/comment/del/' + Math.random(),{id:id},
					function(data) {
						if (data == 1) {
							$('#tbody_' + id).fadeOut("slow",function(){$('#tbody_' + id).remove()});
						} else if(data == -1) {
							window.top.art.dialog({icon: 'error',content:'参数错误!'});
						}else{
							window.top.art.dialog({icon: 'error',content:'系统错误，请稍候重试!'});
					}
				});
		    },
		    lock: true,
		    cancelVal: '关闭',
		    cancel: true //为true等价于function(){}
		});
	}
	//批量删除
	function batchdel(){
		art.dialog({
		    content: '你确定删除这些评论吗?',
		    ok: function () {
		    	var str = 0;
				var id = tag = '';
				$("input[name='ids[]']").each(function() {
					if ($(this).attr('checked') == 'checked') {
						str = 1;
						id += tag + $(this).val();
						tag = ',';
					}
				});
				if (str == 0) {
					window.top.art.dialog({
						icon : 'error',
						content : '请至少选择一条评论!'
					});
					return false;
				}
		    	$.post('/content/comment/del/' + Math.random(),{id:id},
						function(data) {
							if (data == 1) {
								art.dialog({
									time: 2,
									icon: 'succeed',
								    content: '评论删除成功!'
								});
								window.location.reload();
							} else if(data == -1) {
								window.top.art.dialog({icon: 'error',content:'参数错误!'});
							}else{
								window.top.art.dialog({icon: 'error',content:'系统错误，请稍候重试!'});
						}
					});
		    },
		    lock: true,
		    cancelVal: '关闭',
		    cancel: true //为true等价于function(){}
		});	
	}
	
	//查看评论
	function view_comment(id, name) {
		window.top.art.dialog({
			id : 'view_comment'
		}).close();
		window.top.art.dialog({
			yesText : '关闭',
			title : '查看评论：' + name,
			id : 'view_comment',
			iframe : '/content/comment/show/commentid/' + id + '/',
			width : '800',
			height : '500'
		}, function() {
			window.top.art.dialog({
				id : 'edit'
			}).close()
		});
	}
</script>
<body>
	<div class="subnav">
		<div class="content-menu ib-a blue line-x">
			<a href='javascript:;' class="on"><em>评论管理</em></a>
		</div>
	</div>

	<div class="pad_10">
		<div id="searchid">
			<form name="searchform" action="/content/comment/search/"
				method="post">
				<table width="100%" cellspacing="0" class="search-form">
					<tbody>
						<tr>
							<td>
								<div class="explain-col">
									<select name="searchtype">
										<option value='0' selected>原文标题</option>
										<option value='1'>原文ID</option>
										<option value='2'>用户名</option>
									</select> <input name="keyword" type="text" value="" class="input-text" />
									<input type="submit" name="search" class="button" value="搜索" />
								</div>
							</td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>
	</div>
	<div class="pad-lr-10">
		<form name="myform" id="myform" action="/content/comment/delete/"
			method="post">
			<div class="table-list comment">
				<table width="100%">
					<thead>
						<tr>
							<th width="16"><input type="checkbox" value=""
								id="check_box" onclick="selectall('ids[]');"></th>
							<th width="130">发表人</th>
							<th>评论</th>
							<th width="230">原文标题</th>
							<th width="72">管理操作</th>
						</tr>
					</thead>
					<tbody class="add_comment">
						{{foreach item=content from=$Comment_list}}
						<tr id="tbody_{{$content.id}}">
							<td align="center" width="16"><input class="inputcheckbox "
								name="ids[]" value="{{$content.id}}" type="checkbox"></td>
							<td width="130">{{$content.username}}<br />{{$content.ip}}
							</td>
							<td><font color="#888888">于 {{$content.ctime}} 发布</font><br />{{$content.content}}</td>
							<td width="230"><a href="javascript:;"
								onclick="view_comment('{{$content.news.id}}','{{$content.news.title}}');">{{$content.news.title}}</td>
							<td align='center' width="72"><a href="javascript:;"
								onclick="deleteComment({{$content.id}})">删除</a></td>
						</tr>
						{{/foreach}}
					</tbody>
				</table>

				<div class="btn">
					<label for="check_box">全选/取消</label> <input type="button"
						class="button" onclick="batchdel()" value="删除" />
				</div>
				<div id="pages">{{$pageBlock}}</div>
			</div>
		</form>
	</div>
</body>

{{include file="footer.html"}}
